package com.iflytek.cuckoo.kafka;

import com.alibaba.fastjson.JSON;
import com.iflytek.cuckoo.constant.TopicConst;
import com.iflytek.cuckoo.entity.Message;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * <p><一句话功能简述>
 * <p><功能详细描述>
 * <p>
 * <p>Copyright (c) 2018, liangzhang14@iflytek.com All Rights Reserve</p>
 * <p>Company : 科大讯飞</p>
 *
 * @author liangzhang14
 * @version [V1.0, 2019年09月06日 15:38]
 * @see [相关类/方法]
 */
@Slf4j
@Component
public class KafkaReceiver {

    @KafkaListener(topics = {TopicConst.EXECUTOR_TOPIC})
//    @KafkaListener(id="test1",topics = TopicConst.EXECUTOR_TOPIC, containerFactory="kafkaListenerContainerFactory1")
    public void listen(String message) {
        log.info("------------------接收消息 message =" + message);
        Message msg = JSON.parseObject(message, Message.class);
        log.info("MessageConsumer: onMessage: message is: [" + msg + "]");
        log.info("------------------ message =" + message);

    }


//    @KafkaListener(topics = {TopicConst.EXECUTOR_TOPIC})
//    @KafkaListener(id="test2",topics = TopicConst.EXECUTOR_TOPIC, containerFactory="kafkaListenerContainerFactory2")
//    public void listen2(String message) {
//        log.info("------------------接收消息 message1 =" + message);
//        Message msg = JSON.parseObject(message, Message.class);
//        log.info("MessageConsumer: onMessage: message is1: [" + msg + "]");
//        log.info("------------------ message1 =" + message);
//
//    }

}
